I want to write APIs that *require* the caller to have set up
an ostree transaction. It's natural to require passing a guard
to do so. But then we want an accessor for the repo.
}
impl<'a> TransactionGuard<'a> {
+ /// Returns a reference to the repository.
+ pub fn repo(&self) -> &Repo {
+ // SAFETY: This is only set to None in `commit`, which consumes self
+ self.repo.unwrap()
+ }
+
/// Commit this transaction.
pub fn commit<P: IsA<gio::Cancellable>>(
mut self,
let txn = repo
.auto_transaction(NONE_CANCELLABLE)
.expect("prepare transaction");
- let repo_file = repo
+ let repo_file = txn
+ .repo()
.write_mtree(mtree, NONE_CANCELLABLE)
.expect("write mtree")
.downcast::<ostree::RepoFile>()